<template>
  <div>
    <div class="dow6_9">
      <p class="dowimgpsps6_9" v-if="typephone==0">请点击右上角，选择浏览器打开</p>
      <img src="../../assets/images/erweima6_9.jpg" alt class="dowimg6_9" v-if="typephone==2" />
      <p class="dowimgps6_9" v-if="typephone==2">请通过手机浏览器扫描二维码下载简销APP</p>

      <p class="dowimgpsps6_9" v-if="typephone==1">敬请期待!</p>
      <img src="../../assets/images/lougozoxiazai.png" alt class="dowimg16_9" v-if="typephone==3" />
      <p class="dowimgps26_9" v-if="typephone==3">简销</p>
      <p class="dowimgps16_9" v-if="typephone==3">强强联手&nbsp;&nbsp;赚之有道</p>
      <div class="btn336_9" v-if="typephone==3" @click="zouni()">下载APP</div>
    </div>
  </div>
</template>

<script>
import axios from "axios"
export default {
  name: "route",
  data() {
    return {
      code1: "",
      code2: "",
      code3: "",
      code4: "",
      typephone: 0,
      tabBarImgArr: [],
    };
  },
  mounted: function () {
    this.resetPage();
    document.getElementsByTagName("body")[0].className = "add_bg1";
    var _this = this;
    document.title = "下载";
    window.scrollTo(0, 0);

    var userAgent = navigator.userAgent.toLowerCase();

    var ua = navigator.userAgent.toLowerCase();
    // console.log(3434, ua)
    //判断是否是苹果手机，是则是true
    // var isIos = (ua.indexOf('iphone') != -1) || (ua.indexOf('ipad') != -1);
    const u = navigator.userAgent,
      app = navigator.appVersion;
    //const isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
    const isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端

    if (this.$route.query.appDownUrl === "") {
      this.typephone = 1;
      return;
    }

    let data = this.$route.query.appDownUrl.split(",");

    let androidUrl = data.length < 2 ? this.$route.query.appDownUrl : data[0];
    let iosUrl = data.length === 2 && data[1];

    if (isiOS) {
      if (data.length < 2) {
        this.typephone = 1;
        return;
      }
      window.location.href = iosUrl;
    } else {
      window.location.href = androidUrl;
    }

    // if (data.length < 2) {
    //   _this.typephone = 1
    // }
    // if (isIos) {
    //   if (data.length < 2) {
    //     _this.typephone = 1
    //     return
    //   }
    //   location.href = iosUrl
    // } else {
    //   if (ua.match(/Alipay/i) == "alipay") {
    //     location.href = androidUrl
    //   } else if (ua.match(/MicroMessenger/i) == "micromessenger") {
    //     location.href = androidUrl
    //   } else {
    //     if (data.length < 2) {
    //       _this.typephone = 1
    //       return
    //     }
    //     location.href = iosUrl
    //   }
    // }
  },
  methods: {
    resetPage() {
      var htmls = document.getElementsByTagName("html")[0];
      var deviceWidth = document.documentElement.clientWidth;
      htmls.style.fontSize = 100 * (deviceWidth / 750) + "px";
      //  console.log(6666, 100 * (deviceWidth / 750)  + 'px')
      //  /*   $('html').show();*/
    },
    zouni() {
      window.location.href =
        "https://app-client.verajft.com/app/download/Share.apk";
    },
    sub() {
      var _this = this;

        axios({
          //axios请求
          method: "post",
          url: "api/userBase/v1/webRegister",
          data: _this.qs.stringify({
            nickName: _this.code1,
            phone: _this.code2,
            password: _this.code3,
            verifyCode: _this.code4,
            commendCode: sessionStorage.getItem("commendCode"),
          }),
        })
        .then(function (d) {
          if (d.data.code == 0) {
            _this.banner1 = d.data.data;
          } else {
            this.$message(d.data.msg);
          }
        })
        .catch(function (error) {
          //axios请求失败回调
          console.log(error);
        });
    },
    getUrlCode() {
      var e = decodeURI(location.search),
        t = new Object();
      if (-1 != e.indexOf("?"))
        for (var a = e.substr(1), i = a.split("&"), n = 0; n < i.length; n++)
          t[i[n].split("=")[0]] = i[n].split("=")[1];
      return t;
    },
    parentHandleclick() {
      var _this = this;
      _this.ingoxiala = false;
    },
  },
};
</script>

<style scoped>
.dow6_9 {
  width: 100%;
  height: 100vh;
  text-align: center;
  /* margin-left: 100px; */
}

.dowimg6_9 {
  width: 3rem;
  height: 3rem;
  /* float: left; */
  /* margin-left: 2.25rem; */
  margin-top: 25vh;
}

.dowimgps6_9 {
  width: 100%;
  text-align: center;
  font-size: 0.32rem;
  color: #999;
  float: left;
  margin-top: 7vh;
}

.dowimgpsps6_9 {
  width: 100%;
  text-align: center;
  font-size: 0.32rem;
  color: #999;
  float: left;
  margin-top: 40vh;
}

.dowimgps16_9 {
  width: 100%;
  text-align: center;
  font-size: 0.4rem;
  color: #222;
  float: left;
  margin-top: 5vh;
  font-weight: bold;
}

.dowimgps26_9 {
  width: 100%;
  text-align: center;
  font-size: 0.4rem;
  color: #222;
  float: left;
  margin-top: 5vh;
  font-weight: bold;
}

.dowimg16_9 {
  width: 2.5rem;
  height: 2.5rem;
  /* float: left;
    margin-left: 2.5rem; */
  margin-top: 13vh;
}

.btn336_9 {
  width: 100%;
  height: 1rem;
  line-height: 1rem;
  text-align: center;
  color: #fff;
  font-size: 0.34rem;
  /* float: left;
    margin-left: 0.3rem; */
  background-color: #ff3333;
  margin-top: 20vh;
  border-radius: 0.1rem;
}
</style>
